﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Core
{
    public static partial class msg
    {
        public static dynamic deleteMsg(int mid, string username, bool god)
        {
            var sql = new Sql.SqlDataContext();
            var m = sql.Message.FirstOrDefault(row => row.mid == mid);
            if (m == null) return new
                {
                    success = false,
                    msg = "消息不存在"
                };
            if (!god && m.to != username) return new
                    {
                        success = false,
                        msg = "拒绝访问"
                    };
            sql.Message.DeleteOnSubmit(m);
            sql.SubmitChanges();
            return new
            {
                success = true
            };
        }
    }
}